<template>
  <el-cascader
      :placeholder="placeholder"
      v-model="internalValue"
      :options="options"
      :props="{ expandTrigger: 'hover',emitPath:false}"
      clearable
      filterable>
  </el-cascader>
</template>

<script>
export default {
  name: "GenericsSelect",
  data() {
    return {
      options: [],
      selects: {}
    }
  },
  props: ['placeholder', 'type', 'newData', 'value'],
  computed: {
    internalValue: {
      get() {
        return this.value
      },
      set(newValue){
        this.$emit('input',newValue)
      }
    }
  },
  beforeMount() {
    if (this.newData) {
      this.options = this.newData
    } else {
      this.$api.getGenericSelect({params: {"type": this.type}}).then(rep => {
        this.options = rep.data
      })
    }
  }
}
</script>

